package org.jeecg.modules.online.cgreport.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.lang.invoke.SerializedLambda;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.exception.TuringBootException;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.cgreport.entity.OnlCgreportHead;
import org.jeecg.modules.online.cgreport.entity.OnlCgreportItem;
import org.jeecg.modules.online.cgreport.service.IOnlCgreportHeadService;
import org.jeecg.modules.online.cgreport.service.IOnlCgreportItemService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/online/cgreport/item"})
@RestController("onlCgreportItemController")
/* renamed from: org.jeecg.modules.online.cgreport.a.c */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/cgreport/a/c.class */
public class OnlCgreportItemController {

    /* renamed from: a */
    private static final Logger f467a = LoggerFactory.getLogger(OnlCgreportItemController.class);
    @Autowired
    private IOnlCgreportItemService onlCgreportItemService;
    @Autowired
    private IOnlCgreportHeadService onlCgreportHeadService;

    /* renamed from: a */
//    private static /* synthetic */ Object m118a(SerializedLambda serializedLambda) {
//        String implMethodName = serializedLambda.getImplMethodName();
//        boolean z = true;
//        switch (implMethodName.hashCode()) {
//            case -75622813:
//                if (implMethodName.equals("getCode")) {
//                    z = false;
//                    break;
//                }
//                break;
//        }
//        switch (z) {
//            case false:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgreport/entity/OnlCgreportHead") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getCode();
//                    };
//                }
//                break;
//        }
//        throw new IllegalArgumentException("Invalid lambda deserialization");
//    }

    @GetMapping({"/listByHeadId"})
    /* renamed from: a */
    public Result<?> listByHeadId(@RequestParam("headId") String str) {
    	QueryWrapper<OnlCgreportItem> queryWrapper = new QueryWrapper();
        queryWrapper.eq("cgrhead_id", str);
        queryWrapper.orderByAsc("order_num");
        List list = this.onlCgreportItemService.list(queryWrapper);
        Result result = new Result();
        result.setSuccess(true);
        result.setResult(list);
        return result;
    }

    @GetMapping({"/listByHeadCode"})
    /* renamed from: b */
    public Result<?> listByHeadCode(@RequestParam("headCode") String str) {
    	LambdaQueryWrapper<OnlCgreportHead> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgreportHead::getCode, str);
        OnlCgreportHead onlCgreportHead = (OnlCgreportHead) this.onlCgreportHeadService.getOne(lambdaQueryWrapper);
        if (onlCgreportHead == null) {
            throw new TuringBootException("该报表不存在");
        }
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("cgrhead_id", onlCgreportHead.getId());
        queryWrapper.orderByAsc("order_num");
        List list = this.onlCgreportItemService.list(queryWrapper);
        Result result = new Result();
        result.setSuccess(true);
        result.setResult(list);
        return result;
    }

    @GetMapping({"/list"})
    /* renamed from: a */
    public Result<IPage<OnlCgreportItem>> list(OnlCgreportItem onlCgreportItem, @RequestParam(name = "pageNo", defaultValue = "1") Integer num, @RequestParam(name = "pageSize", defaultValue = "10") Integer num2, HttpServletRequest httpServletRequest) {
        Result<IPage<OnlCgreportItem>> result = new Result<>();
        Wrapper initQueryWrapper = QueryGenerator.initQueryWrapper(onlCgreportItem, httpServletRequest.getParameterMap());
        IPage page = this.onlCgreportItemService.page(new Page(num.intValue(), num2.intValue()), initQueryWrapper);
        result.setSuccess(true);
        result.setResult(page);
        return result;
    }

    @PostMapping({"/add"})
    /* renamed from: a */
    public Result<?> add(@RequestBody OnlCgreportItem onlCgreportItem) {
        this.onlCgreportItemService.save(onlCgreportItem);
        return Result.ok("添加成功!");
    }

    @PutMapping({"/edit"})
    /* renamed from: b */
    public Result<?> edit(@RequestBody OnlCgreportItem onlCgreportItem) {
        this.onlCgreportItemService.updateById(onlCgreportItem);
        return Result.ok("编辑成功!");
    }

    @DeleteMapping({"/delete"})
    /* renamed from: c */
    public Result<?> delete(@RequestParam(name = "id", required = true) String str) {
        this.onlCgreportItemService.removeById(str);
        return Result.ok("删除成功!");
    }

    @DeleteMapping({"/deleteBatch"})
    /* renamed from: d */
    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String str) {
        this.onlCgreportItemService.removeByIds(Arrays.asList(str.split(CgformUtil.f233E)));
        return Result.ok("批量删除成功!");
    }

    @GetMapping({"/queryById"})
    /* renamed from: e */
    public Result<OnlCgreportItem> queryById(@RequestParam(name = "id", required = true) String str) {
        Result<OnlCgreportItem> result = new Result<>();
        result.setResult((OnlCgreportItem) this.onlCgreportItemService.getById(str));
        result.setSuccess(true);
        return result;
    }
}
